package com.yunhe.authority.repository.authority;

import com.yunhe.authority.domain.authority.StationStaticData;
import org.springframework.data.neo4j.annotation.Query;
import org.springframework.data.neo4j.repository.Neo4jRepository;
import org.springframework.data.repository.query.Param;

/**
 * 电站静态数据Repository
 * @author zhengbo
 * @date 2020/11/2 15:18
 */
public interface StationStaticDataRepository extends Neo4jRepository<StationStaticData, Long> {

    /**
     * 根据电站代码获得电站静态数据
     * @param stationId 电站ID
     * @return StationStaticData
     */
    @Query("start s=node({stationId}) match(s)-[r:StationStaticData_OF]->(ss) return ss limit 1")
    StationStaticData findByStationId(@Param("stationId") Long stationId);

    /**
     * 电站绑定电站静态数据
     * @param id 电站静态数据ID
     * @param stationId 电站ID
     */
    @Query("start ss=node({id}),s=node({stationId}) create (s)-[r:StationStaticData_OF]->(ss)")
    void bindStationById(@Param("id") Long id, @Param("stationId") Long stationId);


}
